﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VsxFactory.Modeling.VisualStudio;
using System.IO;
using VsxFactory.Modeling.Strategies.Rules;

namespace VsxFactory.Modeling.Strategies.Generators
{
    public class VSTemplateGenerator : INodeGenerator
    {
        public string TemplateName { get; set; }
        public bool Overwrite { get; set; }

        public VSTemplateGenerator() {
        }

        public VSTemplateGenerator(string templateName, bool overwrite = false) {
            TemplateName = templateName;
            Overwrite = overwrite;
        }

        public void Initialize(IStrategyContext context) {
        }

        public bool Generate(IStrategyContext ctx, ref string outputFileNamesession, GenerationSpec element, string @namespace) {
            return true;
        }

        public IVsProjectFileItem AddToSolution(IVsProject projectNode, IVsProjectFileItem node, string fullName) {
            if (node != null) {
                node.AddFromTemplate(TemplateName, fullName);
            }
            else {
                node = projectNode.AddFromTemplate(TemplateName, fullName, Overwrite);
            }
            return node;
        }
    }
}
